package shop.up.product.controller;

import org.springframework.web.bind.annotation.*;
import shop.up.common.result.Result;
import shop.up.model.product.BaseSaleAttr;
import shop.up.model.product.SpuInfo;
import shop.up.product.service.ManageService;

import javax.annotation.Resource;
import java.util.List;

/**
 * SPU {@link SpuManageController}
 *
 * @author Kevin
 * @date 2023/3/29
 */
@RequestMapping("admin/product")
@RestController
public class SpuManageController {

    @Resource
    private ManageService manageService;

    /**
     * 查询基本销售属性列表
     * @return
     */
    @GetMapping("baseSaleAttrList")
    public Result baseSaleAttrList(){
        // 查询所有的销售属性集合
        List<BaseSaleAttr> baseSaleAttrList = manageService.getBaseSaleAttrList();
        return Result.ok(baseSaleAttrList);
    }

    /**
     * 保存spu
     * @param spuInfo
     * @return
     */
    @PostMapping("saveSpuInfo")
    public Result saveSpuInfo(@RequestBody SpuInfo spuInfo){
        // 调用服务层的保存方法
        manageService.saveSpuInfo(spuInfo);
        return Result.ok();
    }
}
